Repetier-Firmware  1.0.0
Repetier.h
Go to the documentation of this file.
1 /*
2  This file is part of Repetier-Firmware.
3 
4  Repetier-Firmware is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  Repetier-Firmware is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
16 
17  This firmware is a nearly complete rewrite of the sprinter firmware
18  by kliment (https://github.com/kliment/Sprinter)
19  which based on Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
20 */
21 
22 #ifndef _REPETIER_H
23 #define _REPETIER_H
24 
25 #include <math.h>
26 #include <stdint.h>
27 //#define REPETIER_VERSION "0.92.10"
28 #define REPETIER_VERSION "1.0.0dev"
29 
30 // Use new communication model for multiple channels - only until stable, then old version gets deleted
31 #define NEW_COMMUNICATION 1
32 // ##########################################################################################
33 // ## Debug configuration ##
34 // ##########################################################################################
35 // These are run time switchable debug flags
36 enum debugFlags {DEB_ECHO = 0x1, DEB_INFO = 0x2, DEB_ERROR = 0x4,DEB_DRYRUN = 0x8,
37  DEB_COMMUNICATION = 0x10, DEB_NOMOVES = 0x20, DEB_DEBUG = 0x40
38  };
39 
41 //#define DEBUG_QUEUE_MOVE
43 //#define DEBUG_PLANNER
46 #define INCLUDE_DEBUG_COMMUNICATION 1
47 // Echo all ascii commands after receiving
48 //#define DEBUG_ECHO_ASCII
51 #define INCLUDE_DEBUG_NO_MOVE 1
52 
55 //#define DEBUG_FREE_MEMORY
56 //#define DEBUG_ADVANCE
58 //#define DEBUG_GENERIC
60 //#define DEBUG_STEPCOUNT
62 //#define DEBUG_COM_ERRORS
64 //#define DEBUG_PRINT
65 //#define DEBUG_DELTA_OVERFLOW
66 //#define DEBUG_DELTA_REALPOS
67 //#define DEBUG_SPLIT
68 //#define DEBUG_JAM
69 // Find the longest segment length during a print
70 //#define DEBUG_SEGMENT_LENGTH
71 // Find the maximum real jerk during a print
72 //#define DEBUG_REAL_JERK
73 // Debug reason for not mounting a sd card
74 //#define DEBUG_SD_ERROR
75 // Uncomment the following line to enable debugging. You can better control debugging below the following line
76 //#define DEBUG
77 
78 #define DEBUG_MSG(x) {if(Printer::debugEcho()) { Com::printFLN(PSTR(x));HAL::delayMilliseconds(20);}}
79 #define DEBUG_MSG2(x,y) {if(Printer::debugEcho()) {Com::printFLN(PSTR(x),y);HAL::delayMilliseconds(20);}}
80 #define DEBUG_MSG_FAST(x) {if(Printer::debugEcho()) {Com::printFLN(PSTR(x));}}
81 #define DEBUG_MSG2_FAST(x,y) {if(Printer::debugEcho()) {Com::printFLN(PSTR(x),y);}}
82 
83 #define CARTESIAN 0
84 #define XY_GANTRY 1
85 #define YX_GANTRY 2
86 #define DELTA 3
87 #define TUGA 4
88 #define BIPOD 5
89 #define XZ_GANTRY 8
90 #define ZX_GANTRY 9
91 #define GANTRY_FAKE 10
92 
93 #define WIZARD_STACK_SIZE 8
94 #define IGNORE_COORDINATE 999999
95 
96 #define IS_MAC_TRUE(x) (defined(x) && x!=0)
97 #define IS_MAC_FALSE(x) (!defined(x) || x==0)
98 #define HAS_PIN(x) (defined(x) && x > -1)
99 
100 // Uncomment if no analyzer is connected
101 //#define ANALYZER
102 // Channel->pin assignments
103 #define ANALYZER_CH0 63 // New move
104 #define ANALYZER_CH1 40 // Step loop
105 #define ANALYZER_CH2 53 // X Step
106 #define ANALYZER_CH3 65 // Y Step
107 #define ANALYZER_CH4 59 // X Direction
108 #define ANALYZER_CH5 64 // Y Direction
109 #define ANALYZER_CH6 58 // xsig
110 #define ANALYZER_CH7 57 // ysig
111 
112 #ifdef ANALYZER
113 #define ANALYZER_ON(a) {WRITE(a,HIGH);}
114 #define ANALYZER_OFF(a) {WRITE(a,LOW);}
115 #else
116 #define ANALYZER_ON(a)
117 #define ANALYZER_OFF(a)
118 #endif
119 
120 #define X_AXIS 0
121 #define Y_AXIS 1
122 #define Z_AXIS 2
123 #define E_AXIS 3
124 #define VIRTUAL_AXIS 4
125 // How big an array to hold X_AXIS..<MAX_AXIS>
126 #define Z_AXIS_ARRAY 3
127 #define E_AXIS_ARRAY 4
128 #define VIRTUAL_AXIS_ARRAY 5
129 
130 
131 #define A_TOWER 0
132 #define B_TOWER 1
133 #define C_TOWER 2
134 #define TOWER_ARRAY 3
135 #define E_TOWER_ARRAY 4
136 
137 #define ANALOG_REF_AREF 0
138 #define ANALOG_REF_AVCC _BV(REFS0)
139 #define ANALOG_REF_INT_1_1 _BV(REFS1)
140 #define ANALOG_REF_INT_2_56 _BV(REFS0) | _BV(REFS1)
141 #define ANALOG_REF ANALOG_REF_AVCC
142 
143 #define HOME_ORDER_XYZ 1
144 #define HOME_ORDER_XZY 2
145 #define HOME_ORDER_YXZ 3
146 #define HOME_ORDER_YZX 4
147 #define HOME_ORDER_ZXY 5
148 #define HOME_ORDER_ZYX 6
149 #define HOME_ORDER_ZXYTZ 7 // Needs hot hotend for correct homing
150 #define HOME_ORDER_XYTZ 8 // Needs hot hotend for correct homing
151 
152 #define NO_CONTROLLER 0
153 #define UICONFIG_CONTROLLER 1
154 #define CONTROLLER_SMARTRAMPS 2
155 #define CONTROLLER_ADAFRUIT 3
156 #define CONTROLLER_FOLTYN 4
157 #define CONTROLLER_VIKI 5
158 #define CONTROLLER_MEGATRONIC 6
159 #define CONTROLLER_RADDS 7
160 #define CONTROLLER_PIBOT20X4 8
161 #define CONTROLLER_PIBOT16X2 9
162 #define CONTROLLER_GADGETS3D_SHIELD 10
163 #define CONTROLLER_REPRAPDISCOUNT_GLCD 11
164 #define CONTROLLER_FELIX 12
165 #define CONTROLLER_RAMBO 13
166 #define CONTROLLER_OPENHARDWARE_LCD2004 14
167 #define CONTROLLER_SANGUINOLOLU_PANELOLU2 15
168 #define CONTROLLER_GAMEDUINO2 16
169 #define CONTROLLER_MIREGLI 17
170 #define CONTROLLER_GATE_3NOVATICA 18
171 #define CONTROLLER_SPARKLCD 19
172 #define CONTROLLER_BAM_DICE_DUE 20
173 #define CONTROLLER_VIKI2 21
174 #define CONTROLLER_LCD_MP_PHARAOH_DUE 22
175 #define CONTROLLER_SPARKLCD_ADAPTER 23
176 #define CONTROLLER_ZONESTAR 24
177 #define CONTROLLER_FELIX_DUE 405
178 #define CONTROLLER_ORCABOTXXLPRO2 25
179 #define CONTROLLER_AZSMZ_12864 26
180 #define CONTROLLER_REPRAPWORLD_GLCD 27
181 
182 //direction flags
183 #define X_DIRPOS 1
184 #define Y_DIRPOS 2
185 #define Z_DIRPOS 4
186 #define E_DIRPOS 8
187 #define XYZ_DIRPOS 7
188 //step flags
189 #define XSTEP 16
190 #define YSTEP 32
191 #define ZSTEP 64
192 #define ESTEP 128
193 //combo's
194 #define XYZ_STEP 112
195 #define XY_STEP 48
196 #define XYZE_STEP 240
197 #define E_STEP_DIRPOS 136
198 #define Y_STEP_DIRPOS 34
199 #define X_STEP_DIRPOS 17
200 #define Z_STEP_DIRPOS 68
201 
202 #define PRINTER_MODE_FFF 0
203 #define PRINTER_MODE_LASER 1
204 #define PRINTER_MODE_CNC 2
205 
206 #define ILLEGAL_Z_PROBE -888
207 
208 // we can not prevent this as some configurations need a parameter and others not
209 #pragma GCC diagnostic ignored "-Wunused-parameter"
210 #pragma GCC diagnostic ignored "-Wunused-variable"
211 
212 #include "Configuration.h"
213 
214 #if (LASER_PWM_MAX > 255 && SUPPORT_LASER) || (CNC_PWM_MAX > 255 && SUPPORT_CNC)
215 typedef uint16_t secondspeed_t;
216 #else
217 typedef uint8_t secondspeed_t;
218 #endif
219 
220 #ifndef SHARED_EXTRUDER_HEATER
221 #define SHARED_EXTRUDER_HEATER 0
222 #endif
223 
224 #ifndef DUAL_X_AXIS
225 #define DUAL_X_AXIS 0
226 #endif
227 
228 #ifndef LAZY_DUAL_X_AXIS
229 #define LAZY_DUAL_X_AXIS 0
230 #endif
231 
232 #ifndef MOVE_X_WHEN_HOMED
233 #define MOVE_X_WHEN_HOMED 0
234 #endif
235 #ifndef MOVE_Y_WHEN_HOMED
236 #define MOVE_Y_WHEN_HOMED 0
237 #endif
238 #ifndef MOVE_Z_WHEN_HOMED
239 #define MOVE_Z_WHEN_HOMED 0
240 #endif
241 
242 #if SHARED_EXTRUDER_HEATER || MIXING_EXTRUDER
243 #undef EXT1_HEATER_PIN
244 #undef EXT2_HEATER_PIN
245 #undef EXT3_HEATER_PIN
246 #undef EXT4_HEATER_PIN
247 #undef EXT5_HEATER_PIN
248 #define EXT1_HEATER_PIN -1
249 #define EXT2_HEATER_PIN -1
250 #define EXT3_HEATER_PIN -1
251 #define EXT4_HEATER_PIN -1
252 #define EXT5_HEATER_PIN -1
253 #endif
254 
255 #ifndef BOARD_FAN_SPEED
256 #define BOARD_FAN_SPEED
257 #endif
258 
259 #ifndef MAX_JERK_DISTANCE
260 #define MAX_JERK_DISTANCE 0.6
261 #endif
262 
263 #if defined(FAST_COREXYZ) && !(DRIVE_SYSTEM==XY_GANTRY || DRIVE_SYSTEM==YX_GANTRY || DRIVE_SYSTEM==XZ_GANTRY || DRIVE_SYSTEM==ZX_GANTRY || DRIVE_SYSTEM==GANTRY_FAKE)
264 #undef FAST_COREXYZ
265 #endif
266 #ifdef FAST_COREXYZ
267 #if DELTA_SEGMENTS_PER_SECOND_PRINT > 30
268 #undef DELTA_SEGMENTS_PER_SECOND_PRINT
269 #define DELTA_SEGMENTS_PER_SECOND_PRINT 30 // core is linear, no subsegments needed
270 #endif
271 #if DELTA_SEGMENTS_PER_SECOND_MOVE > 30
272 #undef DELTA_SEGMENTS_PER_SECOND_MOVE
273 #define DELTA_SEGMENTS_PER_SECOND_MOVE 30
274 #endif
275 #endif
276 
277 inline void memcopy2(void *dest,void *source) {
278  *((int16_t*)dest) = *((int16_t*)source);
279 }
280 inline void memcopy4(void *dest,void *source) {
281  *((int32_t*)dest) = *((int32_t*)source);
282 }
283 
284 #ifndef JSON_OUTPUT
285 #define JSON_OUTPUT 0
286 #endif
287 
288 #if !defined(ZPROBE_MIN_TEMPERATURE) && defined(ZHOME_MIN_TEMPERATURE)
289 #define ZPROBE_MIN_TEMPERATURE ZHOME_MIN_TEMPERATURE
290 #endif
291 
292 #if FEATURE_Z_PROBE && Z_PROBE_PIN < 0
293 #error You need to define Z_PROBE_PIN to use z probe!
294 #endif
295 
296 #if DISTORTION_CORRECTION
297 #if !FEATURE_Z_PROBE
298 #error Distortion correction requires the z probe feature to be enabled and configured!
299 #endif
300 #endif
301 
302 #ifndef MAX_ROOM_TEMPERATURE
303 #define MAX_ROOM_TEMPERATURE 40
304 #endif
305 #ifndef ZHOME_X_POS
306 #define ZHOME_X_POS IGNORE_COORDINATE
307 #endif
308 #ifndef ZHOME_Y_POS
309 #define ZHOME_Y_POS IGNORE_COORDINATE
310 #endif
311 
312 // MS1 MS2 Stepper Driver Micro stepping mode table
313 #define MICROSTEP1 LOW,LOW
314 #define MICROSTEP2 HIGH,LOW
315 #define MICROSTEP4 LOW,HIGH
316 #define MICROSTEP8 HIGH,HIGH
317 #if (MOTHERBOARD == 501) || MOTHERBOARD==502
318 #define MICROSTEP16 LOW,LOW
319 #else
320 #define MICROSTEP16 HIGH,HIGH
321 #endif
322 #define MICROSTEP32 HIGH,HIGH
323 
324 #define GCODE_BUFFER_SIZE 1
325 
326 #ifndef FEATURE_BABYSTEPPING
327 #define FEATURE_BABYSTEPPING 0
328 #define BABYSTEP_MULTIPLICATOR 1
329 #endif
330 
331 #if !defined(Z_PROBE_REPETITIONS) || Z_PROBE_REPETITIONS < 1
332 #define Z_PROBE_SWITCHING_DISTANCE 0.5 // Distance to safely untrigger probe
333 #define Z_PROBE_REPETITIONS 1
334 #endif
335 
336 #ifndef MINMAX_HARDWARE_ENDSTOP_Z2
337 #define MINMAX_HARDWARE_ENDSTOP_Z2 0
338 #define Z2_MINMAX_PIN -1
339 #endif
340 
341 #if MINMAX_HARDWARE_ENDSTOP_Z2 && Z2_MINMAX_PIN > -1
342 #undef MULTI_ZENDSTOP_HOMING
343 #define MULTI_ZENDSTOP_HOMING 1
344 #define MULTI_ZENDSTOP_ALL 3
345 #else
346 #define MULTI_ZENDSTOP_HOMING 0
347 #endif
348 
349 #define SPEED_MIN_MILLIS 400
350 #define SPEED_MAX_MILLIS 60
351 #define SPEED_MAGNIFICATION 100.0f
352 
353 #define SOFTWARE_LEVELING ((FEATURE_SOFTWARE_LEVELING) && (DRIVE_SYSTEM==DELTA))
354 
356 #if !defined(ROD_RADIUS) && DRIVE_SYSTEM == DELTA
357 #define ROD_RADIUS (PRINTER_RADIUS-END_EFFECTOR_HORIZONTAL_OFFSET-CARRIAGE_HORIZONTAL_OFFSET)
358 #endif
359 
360 #ifndef UI_SPEEDDEPENDENT_POSITIONING
361 #define UI_SPEEDDEPENDENT_POSITIONING 1
362 #endif
363 
364 #if DRIVE_SYSTEM==DELTA || DRIVE_SYSTEM==TUGA || DRIVE_SYSTEM==BIPOD || defined(FAST_COREXYZ)
365 #define NONLINEAR_SYSTEM 1
366 #else
367 #define NONLINEAR_SYSTEM 0
368 #endif
369 
370 #ifdef FEATURE_Z_PROBE
371 #define MANUAL_CONTROL 1
372 #endif
373 
374 #define GANTRY ( DRIVE_SYSTEM==XY_GANTRY || DRIVE_SYSTEM==YX_GANTRY || DRIVE_SYSTEM==XZ_GANTRY || DRIVE_SYSTEM==ZX_GANTRY || DRIVE_SYSTEM==GANTRY_FAKE)
375 
376 //Step to split a circle in small Lines
377 #ifndef MM_PER_ARC_SEGMENT
378 #define MM_PER_ARC_SEGMENT 1
379 #define MM_PER_ARC_SEGMENT_BIG 3
380 #else
381 #define MM_PER_ARC_SEGMENT_BIG MM_PER_ARC_SEGMENT
382 #endif
383 //After this count of steps a new SIN / COS calculation is started to correct the circle interpolation
384 #define N_ARC_CORRECTION 25
385 
386 // Test for shared cooler
387 #if NUM_EXTRUDER == 6 && EXT0_EXTRUDER_COOLER_PIN > -1 && EXT0_EXTRUDER_COOLER_PIN == EXT1_EXTRUDER_COOLER_PIN && EXT2_EXTRUDER_COOLER_PIN == EXT3_EXTRUDER_COOLER_PIN && EXT4_EXTRUDER_COOLER_PIN == EXT5_EXTRUDER_COOLER_PIN && EXT0_EXTRUDER_COOLER_PIN == EXT2_EXTRUDER_COOLER_PIN && EXT0_EXTRUDER_COOLER_PIN == EXT4_EXTRUDER_COOLER_PIN
388 #define SHARED_COOLER 1
389 #elif NUM_EXTRUDER == 5 && EXT0_EXTRUDER_COOLER_PIN > -1 && EXT0_EXTRUDER_COOLER_PIN == EXT1_EXTRUDER_COOLER_PIN && EXT2_EXTRUDER_COOLER_PIN == EXT3_EXTRUDER_COOLER_PIN && EXT3_EXTRUDER_COOLER_PIN == EXT5_EXTRUDER_COOLER_PIN && EXT0_EXTRUDER_COOLER_PIN == EXT2_EXTRUDER_COOLER_PIN
390 #define SHARED_COOLER 1
391 #elif NUM_EXTRUDER == 4 && EXT0_EXTRUDER_COOLER_PIN > -1 && EXT0_EXTRUDER_COOLER_PIN == EXT1_EXTRUDER_COOLER_PIN && EXT2_EXTRUDER_COOLER_PIN == EXT3_EXTRUDER_COOLER_PIN && EXT0_EXTRUDER_COOLER_PIN == EXT2_EXTRUDER_COOLER_PIN
392 #define SHARED_COOLER 1
393 #elif NUM_EXTRUDER == 3 && EXT0_EXTRUDER_COOLER_PIN > -1 && EXT0_EXTRUDER_COOLER_PIN == EXT1_EXTRUDER_COOLER_PIN && EXT2_EXTRUDER_COOLER_PIN == EXT0_EXTRUDER_COOLER_PIN
394 #define SHARED_COOLER 1
395 #elif NUM_EXTRUDER == 2 && EXT0_EXTRUDER_COOLER_PIN > -1 && EXT0_EXTRUDER_COOLER_PIN == EXT1_EXTRUDER_COOLER_PIN
396 #define SHARED_COOLER 1
397 #else
398 #define SHARED_COOLER 0
399 #endif
400 
401 #ifndef START_STEP_WITH_HIGH
402 #define START_STEP_WITH_HIGH 1
403 #endif
404 
405 #if NUM_EXTRUDER > 0 && EXT0_TEMPSENSOR_TYPE == 101
406 #define SUPPORT_MAX6675
407 #endif
408 
409 #if NUM_EXTRUDER > 0 && EXT0_TEMPSENSOR_TYPE == 102
410 #define SUPPORT_MAX31855
411 #endif
412 
413 // Test for shared coolers between extruders and mainboard
414 #if EXT0_EXTRUDER_COOLER_PIN > -1 && EXT0_EXTRUDER_COOLER_PIN == FAN_BOARD_PIN
415 #define SHARED_COOLER_BOARD_EXT 1
416 #else
417 #define SHARED_COOLER_BOARD_EXT 0
418 #endif
419 
420 #if defined(UI_SERVO_CONTROL) && UI_SERVO_CONTROL > FEATURE_SERVO
421 #undef UI_SERVO_CONTROL
422 #define UI_SERVO_CONTROL FEATURE_SERVO
423 #endif
424 
425 #if (defined(EXT0_JAM_PIN) && EXT0_JAM_PIN > -1) || (defined(EXT1_JAM_PIN) && EXT1_JAM_PIN > -1) || (defined(EXT2_JAM_PIN) && EXT2_JAM_PIN > -1) || (defined(EXT3_JAM_PIN) && EXT3_JAM_PIN > -1) || (defined(EXT4_JAM_PIN) && EXT4_JAM_PIN > -1) || (defined(EXT5_JAM_PIN) && EXT5_JAM_PIN > -1)
426 #define EXTRUDER_JAM_CONTROL 1
427 #else
428 #define EXTRUDER_JAM_CONTROL 0
429 #endif
430 #ifndef JAM_METHOD
431 #define JAM_METHOD 1
432 #endif
433 
434 #if NUM_EXTRUDER > 0 && EXT0_TEMPSENSOR_TYPE < 101
435 #define EXT0_ANALOG_INPUTS 1
436 #define EXT0_SENSOR_INDEX 0
437 #define EXT0_ANALOG_CHANNEL EXT0_TEMPSENSOR_PIN
438 #define ACCOMMA0 ,
439 #else
440 #define ACCOMMA0
441 #define EXT0_ANALOG_INPUTS 0
442 #define EXT0_SENSOR_INDEX EXT0_TEMPSENSOR_PIN
443 #define EXT0_ANALOG_CHANNEL
444 #endif
445 
446 #if NUM_EXTRUDER > 1 && EXT1_TEMPSENSOR_TYPE < 101
447 #define EXT1_ANALOG_INPUTS 1
448 #define EXT1_SENSOR_INDEX EXT0_ANALOG_INPUTS
449 #define EXT1_ANALOG_CHANNEL ACCOMMA0 EXT1_TEMPSENSOR_PIN
450 #define ACCOMMA1 ,
451 #else
452 #define ACCOMMA1 ACCOMMA0
453 #define EXT1_ANALOG_INPUTS 0
454 #define EXT1_SENSOR_INDEX EXT1_TEMPSENSOR_PIN
455 #define EXT1_ANALOG_CHANNEL
456 #endif
457 
458 #if NUM_EXTRUDER > 2 && EXT2_TEMPSENSOR_TYPE < 101
459 #define EXT2_ANALOG_INPUTS 1
460 #define EXT2_SENSOR_INDEX EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS
461 #define EXT2_ANALOG_CHANNEL ACCOMMA1 EXT2_TEMPSENSOR_PIN
462 #define ACCOMMA2 ,
463 #else
464 #define ACCOMMA2 ACCOMMA1
465 #define EXT2_ANALOG_INPUTS 0
466 #define EXT2_SENSOR_INDEX EXT2_TEMPSENSOR_PIN
467 #define EXT2_ANALOG_CHANNEL
468 #endif
469 
470 #if NUM_EXTRUDER > 3 && EXT3_TEMPSENSOR_TYPE < 101
471 #define EXT3_ANALOG_INPUTS 1
472 #define EXT3_SENSOR_INDEX EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS+EXT2_ANALOG_INPUTS
473 #define EXT3_ANALOG_CHANNEL ACCOMMA2 EXT3_TEMPSENSOR_PIN
474 #define ACCOMMA3 ,
475 #else
476 #define ACCOMMA3 ACCOMMA2
477 #define EXT3_ANALOG_INPUTS 0
478 #define EXT3_SENSOR_INDEX EXT3_TEMPSENSOR_PIN
479 #define EXT3_ANALOG_CHANNEL
480 #endif
481 
482 #if NUM_EXTRUDER > 4 && EXT4_TEMPSENSOR_TYPE < 101
483 #define EXT4_ANALOG_INPUTS 1
484 #define EXT4_SENSOR_INDEX EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS+EXT2_ANALOG_INPUTS+EXT3_ANALOG_INPUTS
485 #define EXT4_ANALOG_CHANNEL ACCOMMA3 EXT4_TEMPSENSOR_PIN
486 #define ACCOMMA4 ,
487 #else
488 #define ACCOMMA4 ACCOMMA3
489 #define EXT4_ANALOG_INPUTS 0
490 #define EXT4_SENSOR_INDEX EXT4_TEMPSENSOR_PIN
491 #define EXT4_ANALOG_CHANNEL
492 #endif
493 
494 #if NUM_EXTRUDER > 5 && EXT5_TEMPSENSOR_TYPE < 101
495 #define EXT5_ANALOG_INPUTS 1
496 #define EXT5_SENSOR_INDEX EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS+EXT2_ANALOG_INPUTS+EXT3_ANALOG_INPUTS+EXT4_ANALOG_INPUTS
497 #define EXT5_ANALOG_CHANNEL ACCOMMA4 EXT5_TEMPSENSOR_PIN
498 #define ACCOMMA5 ,
499 #else
500 #define ACCOMMA5 ACCOMMA4
501 #define EXT5_ANALOG_INPUTS 0
502 #define EXT5_SENSOR_INDEX EXT5_TEMPSENSOR_PIN
503 #define EXT5_ANALOG_CHANNEL
504 #endif
505 
506 #if HAVE_HEATED_BED && HEATED_BED_SENSOR_TYPE < 101
507 #define BED_ANALOG_INPUTS 1
508 #define BED_SENSOR_INDEX EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS+EXT2_ANALOG_INPUTS+EXT3_ANALOG_INPUTS+EXT4_ANALOG_INPUTS+EXT5_ANALOG_INPUTS
509 #define BED_ANALOG_CHANNEL ACCOMMA5 HEATED_BED_SENSOR_PIN
510 #define BED_KOMMA ,
511 #else
512 #define BED_ANALOG_INPUTS 0
513 #define BED_SENSOR_INDEX HEATED_BED_SENSOR_PIN
514 #define BED_ANALOG_CHANNEL
515 #define BED_KOMMA ACCOMMA5
516 #endif
517 
518 #if FAN_THERMO_THERMISTOR_PIN > -1 && FAN_THERMO_PIN > -1
519 #define THERMO_ANALOG_INPUTS 1
520 #define THERMO_ANALOG_INDEX EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS+EXT2_ANALOG_INPUTS+EXT3_ANALOG_INPUTS+EXT4_ANALOG_INPUTS+EXT5_ANALOG_INPUTS+BED_ANALOG_INPUTS
521 #define THERMO_ANALOG_CHANNEL BED_KOMMA FAN_THERMO_THERMISTOR_PIN
522 #define THERMO_COMMA ,
523 #else
524 #define THERMO_ANALOG_INPUTS 0
525 #define THERMO_ANALOG_CHANNEL
526 #define THERMO_COMMA BED_KOMMA
527 #endif
528 
529 #if defined(ADC_KEYPAD_PIN) && (ADC_KEYPAD_PIN > -1)
530 #define KEYPAD_ANALOG_INPUTS 1
531 #define KEYPAD_ANALOG_INDEX EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS+EXT2_ANALOG_INPUTS+EXT3_ANALOG_INPUTS+EXT4_ANALOG_INPUTS+EXT5_ANALOG_INPUTS+BED_ANALOG_INPUTS+THERMO_ANALOG_INPUTS
532 #define KEYPAD_ANALOG_CHANNEL THERMO_COMMA ADC_KEYPAD_PIN
533 #else
534 #define KEYPAD_ANALOG_INPUTS 0
535 #define KEYPAD_ANALOG_CHANNEL
536 #endif
537 
538 #ifndef DEBUG_FREE_MEMORY
539 #define DEBUG_MEMORY
540 #else
541 #define DEBUG_MEMORY Commands::checkFreeMemory();
542 #endif
543 
544 #define NUM_ANALOG_TEMP_SENSORS EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS+EXT2_ANALOG_INPUTS+EXT3_ANALOG_INPUTS+EXT4_ANALOG_INPUTS+EXT5_ANALOG_INPUTS+BED_ANALOG_INPUTS+THERMO_ANALOG_INPUTS
545 
546 #define ANALOG_INPUTS (EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS+EXT2_ANALOG_INPUTS+EXT3_ANALOG_INPUTS+EXT4_ANALOG_INPUTS+EXT5_ANALOG_INPUTS+BED_ANALOG_INPUTS+THERMO_ANALOG_INPUTS+KEYPAD_ANALOG_INPUTS)
547 #if ANALOG_INPUTS > 0
548 
549 #define ANALOG_INPUT_CHANNELS {EXT0_ANALOG_CHANNEL EXT1_ANALOG_CHANNEL EXT2_ANALOG_CHANNEL EXT3_ANALOG_CHANNEL EXT4_ANALOG_CHANNEL EXT5_ANALOG_CHANNEL BED_ANALOG_CHANNEL THERMO_ANALOG_CHANNEL KEYPAD_ANALOG_CHANNEL}
550 #endif
551 
552 #define MENU_MODE_SD_MOUNTED 1
553 #define MENU_MODE_SD_PRINTING 2
554 #define MENU_MODE_PAUSED 4
555 #define MENU_MODE_FAN_RUNNING 8
556 #define MENU_MODE_PRINTING 16
557 #define MENU_MODE_FULL_PID 32
558 #define MENU_MODE_DEADTIME 64
559 #define MENU_MODE_FDM 128
560 #define MENU_MODE_LASER 256
561 #define MENU_MODE_CNC 512
562 
563 #ifndef BENDING_CORRECTION_A
564 #define BENDING_CORRECTION_A 0
565 #endif
566 
567 #ifndef BENDING_CORRECTION_B
568 #define BENDING_CORRECTION_B 0
569 #endif
570 
571 #ifndef BENDING_CORRECTION_C
572 #define BENDING_CORRECTION_C 0
573 #endif
574 
575 #ifndef ACCELERATION_FACTOR_TOP
576 #define ACCELERATION_FACTOR_TOP 100
577 #endif
578 
579 #ifndef KEEP_ALIVE_INTERVAL
580 #define KEEP_ALIVE_INTERVAL 2000
581 #endif
582 
583 #include "HAL.h"
584 #define MAX_VFAT_ENTRIES (2)
585 
586 #define LONG_FILENAME_LENGTH (13*MAX_VFAT_ENTRIES+1)
587 #define SD_MAX_FOLDER_DEPTH 2
588 
589 #include "ui.h"
590 #include "Communication.h"
591 
592 
593 #if UI_DISPLAY_TYPE != DISPLAY_U8G
594 #if (defined(USER_KEY1_PIN) && (USER_KEY1_PIN==UI_DISPLAY_D5_PIN || USER_KEY1_PIN==UI_DISPLAY_D6_PIN || USER_KEY1_PIN==UI_DISPLAY_D7_PIN)) || (defined(USER_KEY2_PIN) && (USER_KEY2_PIN==UI_DISPLAY_D5_PIN || USER_KEY2_PIN==UI_DISPLAY_D6_PIN || USER_KEY2_PIN==UI_DISPLAY_D7_PIN)) || (defined(USER_KEY3_PIN) && (USER_KEY3_PIN==UI_DISPLAY_D5_PIN || USER_KEY3_PIN==UI_DISPLAY_D6_PIN || USER_KEY3_PIN==UI_DISPLAY_D7_PIN)) || (defined(USER_KEY4_PIN) && (USER_KEY4_PIN==UI_DISPLAY_D5_PIN || USER_KEY4_PIN==UI_DISPLAY_D6_PIN || USER_KEY4_PIN==UI_DISPLAY_D7_PIN))
595 #error You cannot use DISPLAY_D5_PIN, DISPLAY_D6_PIN or DISPLAY_D7_PIN for "User Keys" with character LCD display
596 #endif
597 #endif
598 
599 
600 #ifndef SDCARDDETECT
601 #define SDCARDDETECT -1
602 #endif
603 
604 #ifndef SDSUPPORT
605 #define SDSUPPORT 0
606 #endif
607 
608 #if SDSUPPORT
609 #include "SdFat.h"
610 #endif
611 
612 #include "gcode.h"
613 
614 #if ENABLE_BACKLASH_COMPENSATION && DRIVE_SYSTEM != CARTESIAN && !defined(ENFORCE_BACKLASH)
615 #undef ENABLE_BACKLASH_COMPENSATION
616 #define ENABLE_BACKLASH_COMPENSATION false
617 #endif
618 
619 #define uint uint16_t
620 #define uint8 uint8_t
621 #define int8 int8_t
622 #define uint32 uint32_t
623 #define int32 int32_t
624 
625 
626 #undef min
627 #undef max
628 
629 class RMath
630 {
631 public:
632  static inline float min(float a,float b)
633  {
634  if(a < b) return a;
635  return b;
636  }
637  static inline float max(float a,float b)
638  {
639  if(a < b) return b;
640  return a;
641  }
642  static inline int32_t min(int32_t a,int32_t b)
643  {
644  if(a < b) return a;
645  return b;
646  }
647  static inline int32_t min(int32_t a,int32_t b, int32_t c)
648  {
649  if(a < b) return a < c ? a : c;
650  return b<c ? b : c;
651  }
652  static inline float min(float a,float b, float c)
653  {
654  if(a < b) return a < c ? a : c;
655  return b < c ? b : c;
656  }
657  static inline int32_t max(int32_t a,int32_t b)
658  {
659  if(a < b) return b;
660  return a;
661  }
662  static inline int min(int a,int b)
663  {
664  if(a < b) return a;
665  return b;
666  }
667  static inline uint16_t min(uint16_t a,uint16_t b)
668  {
669  if(a < b) return a;
670  return b;
671  }
672  static inline int16_t max(int16_t a,int16_t b)
673  {
674  if(a < b) return b;
675  return a;
676  }
677  static inline uint16_t max(uint16_t a,uint16_t b)
678  {
679  if(a < b) return b;
680  return a;
681  }
682  static inline unsigned long absLong(long a)
683  {
684  return a >= 0 ? a : -a;
685  }
686  static inline int32_t sqr(int32_t a)
687  {
688  return a*a;
689  }
690  static inline uint32_t sqr(uint32_t a)
691  {
692  return a*a;
693  }
694 #ifdef SUPPORT_64_BIT_MATH
695  static inline int64_t sqr(int64_t a)
696  {
697  return a*a;
698  }
699  static inline uint64_t sqr(uint64_t a)
700  {
701  return a*a;
702  }
703 #endif
704 
705  static inline float sqr(float a)
706  {
707  return a*a;
708  }
709 };
710 
711 class RVector3
712 {
713 public:
714  float x, y, z;
715  RVector3(float _x = 0,float _y = 0,float _z = 0):x(_x),y(_y),z(_z) {};
716  RVector3(const RVector3 &a):x(a.x),y(a.y),z(a.z) {};
717 
718 
719 /* const float &operator[](std::size_t idx) const
720  {
721  if(idx == 0) return x;
722  if(idx == 1) return y;
723  return z;
724  };
725 
726  float &operator[](std::size_t idx)
727  {
728  switch(idx) {
729  case 0: return x;
730  case 1: return y;
731  case 2: return z;
732  }
733  return 0;
734  };*/
735 
736  inline bool operator==(const RVector3 &rhs)
737  {
738  return x==rhs.x && y==rhs.y && z==rhs.z;
739  }
740  inline bool operator!=(const RVector3 &rhs)
741  {
742  return !(*this==rhs);
743  }
744  inline RVector3& operator=(const RVector3 &rhs)
745  {
746  if(this!=&rhs)
747  {
748  x = rhs.x;
749  y = rhs.y;
750  z = rhs.z;
751  }
752  return *this;
753  }
754 
755  inline RVector3& operator+=(const RVector3 &rhs)
756  {
757  x += rhs.x;
758  y += rhs.y;
759  z += rhs.z;
760  return *this;
761  }
762 
763  inline RVector3& operator-=(const RVector3 &rhs)
764  {
765  x -= rhs.x;
766  y -= rhs.y;
767  z -= rhs.z;
768  return *this;
769  }
770  inline RVector3 operator-() const
771  {
772  return RVector3(-x,-y,-z);
773  }
774 
775  inline float length() const
776  {
777  return sqrt(x * x + y * y + z * z);
778  }
779 
780  inline float lengthSquared() const
781  {
782  return (x*x+y*y+z*z);
783  }
784 
785  inline RVector3 cross(const RVector3 &b) const
786  {
787  return RVector3(y*b.z-z*b.y,z*b.x-x*b.z,x*b.y-y*b.x);
788  }
789  inline float scalar(const RVector3 &b) const
790  {
791  return (x*b.x+y*b.y+z*b.z);
792  }
793  inline RVector3 scale(float factor) const
794  {
795  return RVector3(x*factor,y*factor,z*factor);
796  }
797  inline void scaleIntern(float factor)
798  {
799  x*=factor;
800  y*=factor;
801  z*=factor;
802  }
803  inline void setMinimum(const RVector3 &b)
804  {
805  x = RMath::min(x,b.x);
806  y = RMath::min(y,b.y);
807  z = RMath::min(z,b.z);
808  }
809  inline void setMaximum(const RVector3 &b)
810  {
811  x = RMath::max(x,b.x);
812  y = RMath::max(y,b.y);
813  z = RMath::max(z,b.z);
814  }
815  inline float distance(const RVector3 &b) const
816  {
817  float dx = b.x-x,dy = b.y-y, dz = b.z-z;
818  return (sqrt(dx*dx+dy*dy+dz*dz));
819  }
820  inline float angle(RVector3 &direction)
821  {
822  return static_cast<float>(acos(scalar(direction)/(length()*direction.length())));
823  }
824 
825  inline RVector3 normalize() const
826  {
827  float len = length();
828  if(len != 0) len = static_cast<float>(1.0/len);
829  return RVector3(x*len,y*len,z*len);
830  }
831 
832  inline RVector3 interpolatePosition(const RVector3 &b, float pos) const
833  {
834  float pos2 = 1.0f - pos;
835  return RVector3(x * pos2 + b.x * pos, y * pos2 + b.y * pos, z * pos2 + b.z * pos);
836  }
837 
838  inline RVector3 interpolateDirection(const RVector3 &b,float pos) const
839  {
840  //float pos2 = 1.0f - pos;
841 
842  float dot = scalar(b);
843  if (dot > 0.9995 || dot < -0.9995)
844  return interpolatePosition(b,pos); // cases cause trouble, use linear interpolation here
845 
846  float theta = acos(dot) * pos; // interpolated position
847  float st = sin(theta);
848  RVector3 t(b);
849  t -= scale(dot);
850  float lengthSq = t.lengthSquared();
851  float dl = st * ((lengthSq < 0.0001f) ? 1.0f : 1.0f / sqrt(lengthSq));
852  t.scaleIntern(dl);
853  t += scale(cos(theta));
854  return t.normalize();
855  }
856 };
857  inline RVector3 operator+(RVector3 lhs, const RVector3& rhs) // first arg by value, second by const ref
858  {
859  lhs.x += rhs.x;
860  lhs.y += rhs.y;
861  lhs.z += rhs.z;
862  return lhs;
863  }
864 
865  inline RVector3 operator-(RVector3 lhs, const RVector3& rhs) // first arg by value, second by const ref
866  {
867  lhs.x -= rhs.x;
868  lhs.y -= rhs.y;
869  lhs.z -= rhs.z;
870  return lhs;
871  }
872 
873  inline RVector3 operator*(const RVector3 &lhs,float rhs) {
874  return lhs.scale(rhs);
875  }
876 
877  inline RVector3 operator*(float lhs,const RVector3 &rhs) {
878  return rhs.scale(lhs);
879  }
880 extern const uint8 osAnalogInputChannels[] PROGMEM;
881 //extern uint8 osAnalogInputCounter[ANALOG_INPUTS];
882 //extern uint osAnalogInputBuildup[ANALOG_INPUTS];
883 //extern uint8 osAnalogInputPos; // Current sampling position
884 #if ANALOG_INPUTS > 0
885 extern volatile uint osAnalogInputValues[ANALOG_INPUTS];
886 #endif
887 #define PWM_HEATED_BED NUM_EXTRUDER
888 #define PWM_BOARD_FAN PWM_HEATED_BED+1
889 #define PWM_FAN1 PWM_BOARD_FAN+1
890 #define PWM_FAN2 PWM_FAN1+1
891 #define PWM_FAN_THERMO PWM_FAN2+1
892 #define NUM_PWM PWM_FAN_THERMO+1
893 extern uint8_t pwm_pos[NUM_PWM]; // 0-NUM_EXTRUDER = Heater 0-NUM_EXTRUDER of extruder, NUM_EXTRUDER = Heated bed, NUM_EXTRUDER+1 Board fan, NUM_EXTRUDER+2 = Fan
894 #if USE_ADVANCE
895 #if ENABLE_QUADRATIC_ADVANCE
896 extern int maxadv;
897 #endif
898 extern int maxadv2;
899 extern float maxadvspeed;
900 #endif
901 
902 
903 #include "Extruder.h"
904 
905 void manage_inactivity(uint8_t debug);
906 
907 extern void finishNextSegment();
908 #if NONLINEAR_SYSTEM
909 extern uint8_t transformCartesianStepsToDeltaSteps(long cartesianPosSteps[], long deltaPosSteps[]);
910 #if SOFTWARE_LEVELING
911 extern void calculatePlane(long factors[], long p1[], long p2[], long p3[]);
912 extern float calcZOffset(long factors[], long pointX, long pointY);
913 #endif
914 #endif
915 extern void linear_move(long steps_remaining[]);
916 #ifndef FEATURE_DITTO_PRINTING
917 #define FEATURE_DITTO_PRINTING false
918 #endif
919 #if FEATURE_DITTO_PRINTING && (NUM_EXTRUDER > 4 || NUM_EXTRUDER < 2)
920 #error Ditto printing requires 2 - 4 extruder.
921 #endif
922 
923 
927 
928 extern void setupTimerInterrupt();
929 extern void motorCurrentControlInit();
930 extern void microstepInit();
931 
932 #include "Printer.h"
933 #include "motion.h"
934 extern long baudrate;
935 
936 #include "HAL.h"
937 
938 
939 extern unsigned int counterPeriodical;
940 extern volatile uint8_t executePeriodical;
941 extern uint8_t counter500ms;
942 extern void writeMonitor();
943 #if FEATURE_FAN_CONTROL
944 extern uint8_t fanKickstart;
945 #endif
946 #if FEATURE_FAN2_CONTROL
947 extern uint8_t fan2Kickstart;
948 #endif
949 
950 #if SDSUPPORT
953 #define SHORT_FILENAME_LENGTH 14
954 #include "SdFat.h"
955 
956 enum LsAction {LS_SerialPrint,LS_Count,LS_GetFilename};
957 class SDCard
958 {
959 public:
960  SdFat fat;
961  //Sd2Card card; // ~14 Byte
962  //SdVolume volume;
963  //SdFile root;
964  //SdFile dir[SD_MAX_FOLDER_DEPTH+1];
965  SdFile file;
966 #if JSON_OUTPUT
967  GCodeFileInfo fileInfo;
968 #endif
969  uint32_t filesize;
970  uint32_t sdpos;
971  //char fullName[13*SD_MAX_FOLDER_DEPTH+13]; // Fill name
972  char *shortname; // Pointer to start of filename itself
973  char *pathend; // File to char where pathname in fullname ends
974  uint8_t sdmode; // 1 if we are printing from sd card, 2 = stop accepting new commands
975  bool sdactive;
976  //int16_t n;
977  bool savetosd;
978  SdBaseFile parentFound;
979 
980  SDCard();
981  void initsd();
982  void writeCommand(GCode *code);
983  bool selectFile(const char *filename,bool silent=false);
984  void mount();
985  void unmount();
986  void startPrint();
987  void pausePrint(bool intern = false);
988  void continuePrint(bool intern = false);
989  void stopPrint();
990  inline void setIndex(uint32_t newpos)
991  {
992  if(!sdactive) return;
993  sdpos = newpos;
994  file.seekSet(sdpos);
995  }
996  void printStatus();
997  void ls();
998 #if JSON_OUTPUT
999  void lsJSON(const char *filename);
1000  void JSONFileInfo(const char *filename);
1001  static void printEscapeChars(const char *s);
1002 #endif
1003  void startWrite(char *filename);
1004  void deleteFile(char *filename);
1005  void finishWrite();
1006  char *createFilename(char *buffer,const dir_t &p);
1007  void makeDirectory(char *filename);
1008  bool showFilename(const uint8_t *name);
1009  void automount();
1010 #ifdef GLENN_DEBUG
1011  void writeToFile();
1012 #endif
1013 private:
1014  uint8_t lsRecursive(SdBaseFile *parent,uint8_t level,char *findFilename);
1015 // SdFile *getDirectory(char* name);
1016 };
1017 
1018 extern SDCard sd;
1019 #endif
1020 
1021 extern volatile int waitRelax; // Delay filament relax at the end of print, could be a simple timeout
1022 extern void updateStepsParameter(PrintLine *p/*,uint8_t caller*/);
1023 
1024 #ifdef DEBUG_PRINT
1025 extern int debugWaitLoop;
1026 #endif
1027 
1028 #if NONLINEAR_SYSTEM
1029 #define NUM_AXIS 4
1030 #endif
1031 
1032 #define STR(s) #s
1033 #define XSTR(s) STR(s)
1034 #include "Commands.h"
1035 #include "Eeprom.h"
1036 
1037 #if CPU_ARCH == ARCH_AVR
1038 #define DELAY1MICROSECOND __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t")
1039 #define DELAY2MICROSECOND __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\tnop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t")
1040 #else
1041 #define DELAY1MICROSECOND HAL::delayMicroseconds(1);
1042 #define DELAY2MICROSECOND HAL::delayMicroseconds(2);
1043 #endif
1044 
1045 #ifdef FAST_INTEGER_SQRT
1046 #define SQRT(x) ( HAL::integerSqrt(x) )
1047 #else
1048 #define SQRT(x) sqrt(x)
1049 #endif
1050 
1052  float sum_xx,sum_xy,sum_yy,sum_x,sum_y,sum_xz,sum_yz,sum_z,n;
1053  public:
1055  reset();
1056  }
1057  void reset() {
1058  sum_xx = sum_xy = sum_yy = sum_x = sum_y = sum_xz = sum_yz = sum_z = n = 0;
1059  }
1060  void addPoint(float x,float y,float z) {
1061  n++;
1062  sum_xx += x * x;
1063  sum_xy += x * y;
1064  sum_yy += y * y;
1065  sum_x += x;
1066  sum_y += y;
1067  sum_xz += x * z;
1068  sum_yz += y * z;
1069  sum_z += z;
1070  }
1071  void createPlane(Plane &plane,bool silent=false) {
1072  float det = (sum_x * (sum_xy * sum_y - sum_x * sum_yy) + sum_xx * (n * sum_yy - sum_y * sum_y) + sum_xy * (sum_x * sum_y - n * sum_xy));
1073  plane.a = ((sum_xy * sum_y - sum_x * sum_yy) * sum_z + (sum_x * sum_y - n * sum_xy) * sum_yz + sum_xz * (n * sum_yy - sum_y * sum_y)) / det;
1074  plane.b = ((sum_x * sum_xy - sum_xx * sum_y) * sum_z + (n * sum_xx - sum_x * sum_x) * sum_yz + sum_xz * (sum_x * sum_y - n * sum_xy)) / det;
1075  plane.c = ((sum_xx * sum_yy - sum_xy * sum_xy) * sum_z + (sum_x * sum_xy - sum_xx * sum_y) * sum_yz + sum_xz * (sum_xy * sum_y - sum_x * sum_yy)) / det;
1076  if(!silent) {
1077  Com::printF(PSTR("plane: a = "),plane.a,4);
1078  Com::printF(PSTR(" b = "),plane.b,4);
1079  Com::printFLN(PSTR(" c = "),plane.c,4);
1080  }
1081  }
1082 };
1083 
1084 #include "Drivers.h"
1085 
1086 #include "Events.h"
1087 #if defined(CUSTOM_EVENTS)
1088 #include "CustomEvents.h"
1089 #endif
1090 
1091 // must be after CustomEvents as it might include definitions from there
1092 #include "DisplayList.h"
1093 
1094 #endif
float lengthSquared() const
Definition: Repetier.h:780
static int32_t max(int32_t a, int32_t b)
Definition: Repetier.h:657
bool operator==(const RVector3 &rhs)
Definition: Repetier.h:736
float x
Definition: Repetier.h:714
static uint16_t max(uint16_t a, uint16_t b)
Definition: Repetier.h:677
static float sqr(float a)
Definition: Repetier.h:705
static int32_t min(int32_t a, int32_t b)
Definition: Repetier.h:642
RVector3(float _x=0, float _y=0, float _z=0)
Definition: Repetier.h:715
float length() const
Definition: Repetier.h:775
Definition: Repetier.h:37
RVector3 interpolateDirection(const RVector3 &b, float pos) const
Definition: Repetier.h:838
volatile uint8_t executePeriodical
Definition: Extruder.cpp:26
Definition: Repetier.h:1051
static int16_t max(int16_t a, int16_t b)
Definition: Repetier.h:672
RVector3(const RVector3 &a)
Definition: Repetier.h:716
Definition: gcode.h:91
static void printFLN(FSTRINGPARAM(text))
Definition: Communication.cpp:526
RVector3 normalize() const
Definition: Repetier.h:825
static unsigned long absLong(long a)
Definition: Repetier.h:682
#define uint8
Definition: Repetier.h:620
RVector3 operator-() const
Definition: Repetier.h:770
Definition: Repetier.h:37
RVector3 scale(float factor) const
Definition: Repetier.h:793
void memcopy2(void *dest, void *source)
Definition: Repetier.h:277
float z
Definition: Repetier.h:714
RVector3 interpolatePosition(const RVector3 &b, float pos) const
Definition: Repetier.h:832
void microstepInit()
Definition: Commands.cpp:727
float y
Definition: Repetier.h:714
unsigned int counterPeriodical
Definition: Extruder.cpp:25
long baudrate
Communication speed rate.
Definition: motion.cpp:70
uint8_t counter500ms
Definition: Extruder.cpp:27
void manage_inactivity(uint8_t debug)
Definition: Repetier.h:36
void setMaximum(const RVector3 &b)
Definition: Repetier.h:809
#define ANALOG_INPUTS
number of analog input signals. Normally 1 for each temperature sensor
Definition: Repetier.h:546
static float min(float a, float b, float c)
Definition: Repetier.h:652
bool operator!=(const RVector3 &rhs)
Definition: Repetier.h:740
millis_t previousMillisCmd
Definition: motion.cpp:67
Definition: Repetier.h:36
Definition: motion.h:138
float angle(RVector3 &direction)
Definition: Repetier.h:820
RVector3 & operator+=(const RVector3 &rhs)
Definition: Repetier.h:755
float distance(const RVector3 &b) const
Definition: Repetier.h:815
void createPlane(Plane &plane, bool silent=false)
Definition: Repetier.h:1071
volatile uint osAnalogInputValues[ANALOG_INPUTS]
Definition: Extruder.cpp:45
static int32_t min(int32_t a, int32_t b, int32_t c)
Definition: Repetier.h:647
uint8_t secondspeed_t
Definition: Repetier.h:217
PlaneBuilder()
Definition: Repetier.h:1054
void addPoint(float x, float y, float z)
Definition: Repetier.h:1060
float maxadvspeed
Definition: motion.cpp:76
static uint32_t sqr(uint32_t a)
Definition: Repetier.h:690
volatile int waitRelax
Definition: motion.cpp:79
static int32_t sqr(int32_t a)
Definition: Repetier.h:686
Definition: Repetier.h:37
uint8_t pwm_pos[NUM_PWM]
Definition: motion.cpp:78
Definition: Repetier.h:36
const uint8 osAnalogInputChannels [] PROGMEM
Definition: Commands.cpp:24
char fullName[LONG_FILENAME_LENGTH *SD_MAX_FOLDER_DEPTH+SD_MAX_FOLDER_DEPTH+1]
Definition: SDCard.cpp:27
float a
Definition: Printer.h:126
Definition: Repetier.h:629
uint8_t fanKickstart
Definition: Commands.cpp:234
void motorCurrentControlInit()
uint32_t millis_t
Definition: HAL.h:158
void memcopy4(void *dest, void *source)
Definition: Repetier.h:280
static void printF(FSTRINGPARAM(text))
#define LONG_FILENAME_LENGTH
Definition: Repetier.h:586
char tempLongFilename[LONG_FILENAME_LENGTH+1]
Definition: SDCard.cpp:26
Definition: Repetier.h:36
RVector3 cross(const RVector3 &b) const
Definition: Repetier.h:785
Definition: Printer.h:123
millis_t stepperInactiveTime
Definition: motion.cpp:69
static uint16_t min(uint16_t a, uint16_t b)
Definition: Repetier.h:667
FAT short directory entry.
Definition: FatStructs.h:321
void setMinimum(const RVector3 &b)
Definition: Repetier.h:803
#define uint
Definition: Repetier.h:619
void updateStepsParameter(PrintLine *p)
void scaleIntern(float factor)
Definition: Repetier.h:797
static float min(float a, float b)
Definition: Repetier.h:632
#define NUM_PWM
Definition: Repetier.h:892
void reset()
Definition: Repetier.h:1057
SDCard sd
Definition: SDCard.cpp:31
float c
Definition: Printer.h:126
millis_t maxInactiveTime
Definition: motion.cpp:68
RVector3 operator+(RVector3 lhs, const RVector3 &rhs)
Definition: Repetier.h:857
RVector3 operator-(RVector3 lhs, const RVector3 &rhs)
Definition: Repetier.h:865
debugFlags
Definition: Repetier.h:36
RVector3 & operator-=(const RVector3 &rhs)
Definition: Repetier.h:763
void finishNextSegment()
float b
Definition: Printer.h:126
#define SD_MAX_FOLDER_DEPTH
Definition: Repetier.h:587
void writeMonitor()
Writes monitored temperatures.
Definition: Extruder.cpp:2495
static int min(int a, int b)
Definition: Repetier.h:662
int maxadv2
Definition: motion.cpp:75
float scalar(const RVector3 &b) const
Definition: Repetier.h:789
RVector3 operator*(const RVector3 &lhs, float rhs)
Definition: Repetier.h:873
void linear_move(long steps_remaining[])
Definition: Repetier.h:711
RVector3 & operator=(const RVector3 &rhs)
Definition: Repetier.h:744
float sum_z
Definition: Repetier.h:1052
void setupTimerInterrupt()
static float max(float a, float b)
Definition: Repetier.h:637